feat(sdk): Mapping cache constraints
#2901
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added
maxSizeandmaxAgeoptions to theMappingclass. These are needed in follow-up PR (#2903).Added two builder functions:
createCacheMap()andcreateLazyMap(). This way the user of the class needs to decide if the Mapping if is a cache or just a lazy loading map. For caches it is required to configuremaxSize.Type safety
The constructor of
Mappingis annotated as@internalso that in encourages the usage of the builder functions. If we make it private, the builder functions needs to have access to it somehow. Could e.g. be static methods. Or we could exportMappingas a type.Testing
In unit tests we test the basic functionality for the lazy map, and use cache map only test the size limitations. This is maybe ok as in the
Mappingthe differences are abstracted out to thedelegate(which is either a LRU cache or plainMap).Future improvements
Mappinginstead ofCacheMapinStreamRegistry/StreamStorageRegistryand remove theCacheMapclass